package com.cgly.medical.config;

import com.cgly.medical.domain.AppointmentTime;
import com.cgly.medical.mapper.AppointmentTimeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 黄浩然
 */
@Component
public class ScheduledTime {


    @Autowired
    private AppointmentTimeMapper appointmentTimeMapper;
//    @Scheduled(cron = "0 0 19 1/1 * ?")
    @Scheduled(cron="0 05 19 ? * *")
    public void appointmentTimeScheduled(){
        List<AppointmentTime> appointmentTimes = appointmentTimeMapper.selectAllAppointmentTime();
        for (AppointmentTime appointmentTime: appointmentTimes) {
            appointmentTime.setEight(0);
            appointmentTime.setNine(0);
            appointmentTime.setTen(0);
            appointmentTime.setEleven(0);
            appointmentTime.setFourteen(0);
            appointmentTime.setFifteen(0);
            appointmentTime.setSixteen(0);
            appointmentTime.setSeventeen(0);
            appointmentTimeMapper.updateAppointmentTime(appointmentTime);
        }

    }

}
